import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            name : 'login',
            path: '/login',
            component: () => import('@/views/Login/index.vue')
        },
        {
            name:'home',
            path: '/home',
            component: () => import('@/views/Home/index.vue'),
            children: [
                {
                    name:'data_list',
                    path: '/home/data_list',
                    component: () => import('@/views/Home/List/data_list.vue')
                },
                {
                    name:'user_list',
                    path: '/home/user_list',
                    component: () => import('@/views/Home/List/user_list.vue')
                },
            ]
        },
        {
            path: '/',
            redirect: '/login'
        }
    ]
})

// router.addRoute({
//     name:'shom',
//     path:' /shom',
//     component :shom
// })

// router.beforeEach((to, from, next) => {
//     if (to.path == '/login') {
//         next();
//     } else {
//         const token = localStorage.getItem('token');
//         if (token) {
//             next();
//         } else {
//             next('/login')
//         }
//     }
// })




export default router;